import java.util.ArrayList;

public class StringListElement{
	String value;//the string we searched for
	ArrayList<StringListElementInfo> info;


	public StringListElement(String value, String filename, int lineNumber, int startInd, int endInd){
		this.value = value;
		this.info = new ArrayList<StringListElementInfo>();
		this.info.add(new StringListElementInfo(filename, lineNumber, startInd, endInd));
	}

	public String toString(){
		return "<\"" + value + "\"=" + info.toString() + ">";
	}

	@Override
	public boolean equals(Object o) {
		if (!(o instanceof StringListElement)) return false;
		StringListElement sle = (StringListElement)o;
		return value != null && value.equals(sle.value);
	}

	public void addInfo(ArrayList<StringListElementInfo> sleiArr){
		for (int i = 0; i < sleiArr.size(); i++){
			if (!info.contains(sleiArr.get(i))){
				info.add(sleiArr.get(i));
			}
		}
		/*for (int i = 0; i < sleiArr.size(); i++){
			found = false;
			for (int j = 0; j < info.size(); j++){
				if (info.get(j).equals(sleiArr.get(i))){
					found = true;
					break;
				}
			}
			if (!found){

			}
		}*/
	}


	public class StringListElementInfo{
		String filename;
		int lineNumber, startInd, endInd;
		public StringListElementInfo(String filename, int lineNumber, int startInd, int endInd){
			this.filename = filename;
			this.lineNumber = lineNumber;
			this.startInd = startInd;
			this.endInd = endInd;
		}

		public boolean equals(Object o){
			if (!(o instanceof StringListElementInfo)) return false;
			StringListElementInfo slei = (StringListElementInfo)o;
			return filename != null && filename.equals(slei.filename) && slei.lineNumber == lineNumber && slei.startInd == startInd && slei.endInd == endInd;
		}

		public String toString(){
			return filename + ": (" + lineNumber + ", " + startInd + ", " + endInd + ")";
		}
	}
}
